#ifndef EVENT_MANAGER_H_
#define EVENT_MANAGER_H_

#include "base/base.h"

#define EV_READ 1
#define EV_WRITE (1 << 1)

struct Event {
  int32 fd;
  uint8 event;
  void (*cb)(int fd, uint8 event, void* ctx);
  void* contex;
};

namespace unet {
class EventManager {
 public:
  virtual ~EventManager() {
  }
  static EventManager* CreateEventManager();

  virtual bool Init() = 0;

  virtual bool Add(Event* ev) = 0;
  virtual bool Mod(Event* ev) = 0;
  virtual void Del(Event* ev) = 0;

  virtual void Loop() = 0;
  virtual void LoopInAnotherThread() = 0;

  virtual void Stop() = 0;

 protected:
  EventManager() {
  }

 private:

  DISALLOW_COPY_AND_ASSIGN(EventManager);
};

}

#endif
